﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace NAVE_Alice_demo.Cena08.Outros
{
    public class RachaCuca
    {
        //********Cena
        Texture2D fundo, fundo2, fundo3;
        //********Cena

        //********Jogo
        Texture2D ganhou, perdeu, tempogif;
        //********Jogo

        Vector2 cenario_quadro01;
        Vector2 cenario_quadro02;
        Vector2 cenario_quadro03;
        Vector2 memory, memoryant;

        
        
        
        Texture2D[] rank = new Texture2D[6];

        Seta seta;
        Quadrados quag, quaa, quat, quao, quap, quaaa, quai, quas, quac, quah, quaaaa, quaspace;
        Paralaxe cenario_01, cenario_02, cenario_03;
        Anime bebe, sapo, morcego, crocodilo, unicornio, lua;
        
       
        Double time, timefinal;
        SpriteFont font;
        Song meuSom;
        Song som_amb;
        SoundEffect meuclic;
        MouseState mouse_atual, mouse_anterior;
        
        //  SoundEffect  som_lua;//,som_morce,som_porco,som_croco,som_uni,som_sapo;
        
        string gato, pais, cha;
        int trocar = 0;
        int velo1, velo2, velo3;
        int diferenca = 110, diferencay = 110, ordem, venceu = 0, points, reinicio = 0;
        int checkgato, checkpais, checkcha; //condiçoes para checar a posição das letras(posiçoes certas)
        
        bool ani, sapo_anima, morcego_anima, croco_anima, lua_anima;
        bool verificar, som1, som2, perdeubol, tela1;
        
        #region sidequest
        //Textures
        Texture2D t2dGato;
        Texture2D t2dLagarto;
        Texture2D t2dRato;
        Texture2D[] t2dTela = new Texture2D[3];
        Texture2D t2dPronto;
        Texture2D t2dVoltar;

        //Vectors
        Vector2 v2dGato;
        Vector2 v2dLagarto;
        Vector2 v2dRato;
        Vector2 v2dTela;
        Vector2 v2dPosi;
        Vector2 v2dPosiNPC;
        Vector2 v2dPronto;
        Vector2 v2dVoltar;


        //int
        int Escolha = 90;
        int EscolhaNPC;
        int Status = 90;
        int Contador = 0;
        int jafoi = 0;
        /*Status = 0 / Vitória
         *Status = 1 / Derrota
         *Status = 2 / Empate */

        //Random
        Random SortNPC = new Random();


        //Bool
        bool Turno;
        bool Resultado = false;
        bool pronto = false;
        bool UmaEscolha = false;
        bool sortiado = false;
        bool TempoPronto = false;
        bool sidebebe = false;
        bool JogarSidequest = false;
        bool voltarCena = false;
        bool ClickPronto = false;
        bool JogouSideQuest = false;

        double Tempo;

        public enum Estados
        {
            Cena, Jogo, SideQuest, Introducao
        }

        public static Estados estadoAtual;
        
        #endregion

        #region Bagunça
        public RachaCuca()
        {
        
        }
        
        public void LoadContent(ContentManager Content)
        {
            estadoAtual = Estados.Cena;

            #region Sidequest

            t2dGato = Content.Load<Texture2D>("Cena_08/gato");
            t2dLagarto = Content.Load<Texture2D>("Cena_08/lagarto");
            t2dRato = Content.Load<Texture2D>("Cena_08/rato");
            t2dPronto = Content.Load<Texture2D>("Cena_08/pronto");

            t2dVoltar = Content.Load<Texture2D>("cena_08/voltar");
            v2dVoltar = new Vector2(100, 500);

            t2dTela[0] = Content.Load<Texture2D>("Cena_08/Sorte");
            t2dTela[1] = Content.Load<Texture2D>("Cena_08/Azar");
            t2dTela[2] = Content.Load<Texture2D>("Cena_08/empate");


            v2dGato = new Vector2(20, 300);
            v2dLagarto = new Vector2(340, 300);
            v2dRato = new Vector2(600, 300);
            v2dTela = new Vector2(30, 200);
            v2dPosi = new Vector2(100, 100);
            v2dPosiNPC = new Vector2(650, 100);
            v2dPronto = new Vector2(370, 20);

            Turno = true;
            // x:720 
            //y:450
            #endregion

            #region paralaxe

            som_amb = Content.Load<Song>("Cena_08/Cena08_ambiente");

            seta = new Seta(Content.Load<Texture2D>("Cena_08/CursorVerde_Alice"));
            cenario_01 = new Paralaxe(Content.Load<Texture2D>("Cena_08/Cena08_cenario_01"),
               new Vector2(0, 0));


            cenario_02 = new Paralaxe(Content.Load<Texture2D>("Cena_08/Cena08_cenario_02"),
                new Vector2(0, 0));


            cenario_03 = new Paralaxe(Content.Load<Texture2D>("Cena_08/Cena08_cenario_03"),
                new Vector2(0, 0));


            bebe = new Anime(Content.Load<Texture2D>("Cena_08/Cena08_bebeporco_puzzle"), //texture
          new Vector2(280, 349),             //tamanho
          new Vector2(1600, 390),            //posicao
          new Vector2(0, 0),                 //posicao_q
          (int)(0),                           // quadro_atual
          (int)(3),                           //quadros_totais
          (int)(20),                          //taxa_quadro
          (int)(0));                          //tempo_quadro

            sapo = new Anime(Content.Load<Texture2D>("Cena_08/Cena08_sapo_transquest"),   //texture
          new Vector2(121, 246),              //tamanho
          new Vector2(585, 390),              //posicao
          new Vector2(0, 0),                  //posicao_q
          (int)(0),                           //quadro_atual
          (int)(5),                           //quadros_totais
          (int)(7),                           //taxa_quadro
          (int)(0));                          //tempo_quadro

            morcego = new Anime(Content.Load<Texture2D>("Cena_08/Cena08_morcego_nonquest"),   //texture
          new Vector2(152, 209),              //tamanho
          new Vector2(964, 93),               //posicao
          new Vector2(0, 0),                  //posicao_q
          (int)(0),                           //quadro_atual
          (int)(3),                           //quadros_totais
          (int)(7),                          //taxa_quadro
          (int)(0));                          //tempo_quadro

            unicornio = new Anime(Content.Load<Texture2D>("Cena_08/Cena08_unicornio_nonquest"),   //texture
         new Vector2(341, 468),              //tamanho
         new Vector2(100, 400),               //posicao
         new Vector2(0, 0),                  //posicao_q
         (int)(0),                           //quadro_atual
         (int)(3),                           //quadros_totais
         (int)(15),                          //taxa_quadro
         (int)(0));                          //tempo_quadro

            crocodilo = new Anime(Content.Load<Texture2D>("Cena_08/Cena08_crocodilo_sidequest"),   //texture
       new Vector2(250, 173),              //tamanho
       new Vector2(860, 360),               //posicao
       new Vector2(0, 0),                  //posicao_q
       (int)(0),                           //quadro_atual
       (int)(7),                           //quadros_totais
       (int)(5),                          //taxa_quadro
       (int)(0));                          //tempo_quadro

            lua = new Anime(Content.Load<Texture2D>("Cena_08/Cena08_lua_nonquest"),   //texture
        new Vector2(1246, 356),              //tamanho
        new Vector2(80, 25),                //posicao
        new Vector2(0, 0),                  //posicao_q
        (int)(0),                           //quadro_atual
        (int)(3),                           //quadros_totais
        (int)(20),                          //taxa_quadro
        (int)(0));                          //tempo_quadro

            ani = true;
            sapo_anima = false;
            morcego_anima = false;
            croco_anima = false;
            velo1 = (int)(3 * 0.42);
            velo2 = (int)(2.4);
            velo3 = (int)(3.5);
            lua_anima = true;

            # endregion

            # region Jogo
            Random fila = new Random();
            meuSom = Content.Load<Song>("Cena_08/destination");


            ordem = fila.Next(1, 3);
            if (ordem == 1)
            {
                quaa = new Quadrados(Content.Load<Texture2D>("Cena_08/Agato"), new Vector2(320, 210));
                quag = new Quadrados(Content.Load<Texture2D>("Cena_08/g"), new Vector2(425, 210));
                quao = new Quadrados(Content.Load<Texture2D>("Cena_08/o"), new Vector2(530, 210));
                quat = new Quadrados(Content.Load<Texture2D>("Cena_08/t"), new Vector2(635, 210));
                quac = new Quadrados(Content.Load<Texture2D>("Cena_08/c"), new Vector2(320, 315));
                quaaaa = new Quadrados(Content.Load<Texture2D>("Cena_08/acha"), new Vector2(425, 315));
                quah = new Quadrados(Content.Load<Texture2D>("Cena_08/h"), new Vector2(530, 315));
                quaaa = new Quadrados(Content.Load<Texture2D>("Cena_08/apais"), new Vector2(635, 315));
                quap = new Quadrados(Content.Load<Texture2D>("Cena_08/p"), new Vector2(320, 420));
                quas = new Quadrados(Content.Load<Texture2D>("Cena_08/s"), new Vector2(425, 420));
                quai = new Quadrados(Content.Load<Texture2D>("Cena_08/i"), new Vector2(635, 420));
                quaspace = new Quadrados(Content.Load<Texture2D>("Cena_08/00"), new Vector2(530, 420));
            }
            if (ordem == 2)
            {
                quag = new Quadrados(Content.Load<Texture2D>("Cena_08/g"), new Vector2(320, 210));
                quaa = new Quadrados(Content.Load<Texture2D>("Cena_08/agato"), new Vector2(425, 210));
                quat = new Quadrados(Content.Load<Texture2D>("Cena_08/t"), new Vector2(530, 210));
                quao = new Quadrados(Content.Load<Texture2D>("Cena_08/o"), new Vector2(635, 210));
                quap = new Quadrados(Content.Load<Texture2D>("Cena_08/p"), new Vector2(320, 315));
                quaaa = new Quadrados(Content.Load<Texture2D>("Cena_08/apais"), new Vector2(425, 315));
                quai = new Quadrados(Content.Load<Texture2D>("Cena_08/i"), new Vector2(530, 315));
                quas = new Quadrados(Content.Load<Texture2D>("Cena_08/s"), new Vector2(635, 315));
                quac = new Quadrados(Content.Load<Texture2D>("Cena_08/c"), new Vector2(320, 420));
                quah = new Quadrados(Content.Load<Texture2D>("Cena_08/h"), new Vector2(425, 420));
                quaaaa = new Quadrados(Content.Load<Texture2D>("Cena_08/acha"), new Vector2(635, 420));
                quaspace = new Quadrados(Content.Load<Texture2D>("Cena_08/00"), new Vector2(530, 420));
            }

            font = Content.Load<SpriteFont>("Cena_08/SpriteFont2");
            ganhou = Content.Load<Texture2D>("Cena_08/ganhou");
            perdeu = Content.Load<Texture2D>("Cena_08/perdeu");
            tempogif = Content.Load<Texture2D>("Cena_08/tempogif");
            fundo = Content.Load<Texture2D>("Cena_08/Cena08_cenario_01");
            fundo2 = Content.Load<Texture2D>("Cena_08/Cena08_cenario_02");
            fundo3 = Content.Load<Texture2D>("Cena_08/Cena08_cenario_03");
            meuclic = Content.Load<SoundEffect>("Cena_08/checked");
            som1 = true;
            som2 = false;
            perdeubol = false;
            tela1 = false;

            #endregion
        }

        public void Update(GameTime gameTime)
        {
            if (Game1.tecladoAtual.IsKeyDown(Keys.P) && !Game1.tecladoAnterior.IsKeyDown(Keys.P))
            {
                EnumCena.cenaAtual = EnumCena.Cena.cena9;
            }
            mouse_atual = Mouse.GetState();


            if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
            {
                if (
                mouse_atual.X > bebe.posicao.X &&
                mouse_atual.X < bebe.posicao.X + bebe.tamanho.X &&
                mouse_atual.Y > bebe.posicao.Y &&
                mouse_atual.Y < bebe.posicao.Y + bebe.tamanho.Y)
                {
                    sidebebe = true;
                    JogarSidequest = true;
                    if (jafoi == 0)
                    {
                        estadoAtual = Estados.SideQuest;
                    }
                    jafoi = 1;
                }
            }
            switch (estadoAtual)
            {
                case Estados.Cena:
                    
                    if (som1 == true)
                    {
                       // MediaPlayer.Play(som_amb);
                       // som1 = false;
                       //MediaPlayer.IsRepeating = true;
                    }
               
                    #region trocar 0 CENA //paralaxe
                    if (trocar == 0)
                    {
                        
                        # region  seta fora de Tela
                        if ((mouse_atual.X + 5 >= 1024) &&
                            !(cenario_quadro01.X >= cenario_01.texture.Width - 1024))
                        {
                            cenario_quadro01.X += velo1;
                            lua.posicao.X -= velo1;
                            cenario_quadro02.X += velo2;
                            sapo.posicao.X -= velo2;
                            crocodilo.posicao.X -= velo2;
                            cenario_quadro03.X += velo3;
                            morcego.posicao.X -= velo3;
                            unicornio.posicao.X -= velo3;
                            bebe.posicao.X -= (float)(6.5);
                        }


                        if ((mouse_atual.X <= 0) &&
                          !(cenario_quadro01.X <= cenario_01.texture.Width - 1150))
                        {


                            cenario_quadro01.X -= velo1;
                            lua.posicao.X += velo1;
                            cenario_quadro02.X -= velo2;
                            sapo.posicao.X += velo2;
                            crocodilo.posicao.X += velo2;
                            cenario_quadro03.X -= velo3;
                            morcego.posicao.X += velo3;
                            unicornio.posicao.X += velo3;
                            bebe.posicao.X += (float)(6.5);
                        }
                        # endregion


                        //Código para animaçoes
                        if (mouse_atual.X > lua.posicao.X &&
                             mouse_atual.Y > lua.posicao.Y &&
                             mouse_atual.X < lua.posicao.X + lua.tamanho.X &&
                             mouse_atual.Y < lua.posicao.Y + lua.tamanho.Y)
                        {
                            lua_anima = true;
                            //som_lua = Content.Load<SoundEffect>("Cena08_lua");
                            //som_lua.Play();
                        }
                        else
                        {
                            lua.quadro_atual = 0;

                        }

                        if (mouse_atual.X > morcego.posicao.X &&
                             mouse_atual.Y > morcego.posicao.Y &&
                             mouse_atual.X < morcego.posicao.X + morcego.tamanho.X &&
                             mouse_atual.Y < morcego.posicao.Y + morcego.tamanho.Y)
                        {
                            morcego_anima = true;
                            //som_morce = Content.Load<SoundEffect>("Cena08_morcego~1");
                            //som_morce.Play();
                        }
                        else
                        {
                            morcego.quadro_atual = 0;

                        }
                        if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                            if (
                             Mouse.GetState().X > sapo.posicao.X &&
                             Mouse.GetState().X < sapo.posicao.X + sapo.tamanho.X &&
                             Mouse.GetState().Y > sapo.posicao.Y &&
                             Mouse.GetState().Y < sapo.posicao.Y + sapo.tamanho.Y)
                            {
                                sapo.quadro_atual = 0;
                                sapo_anima = true;
                                estadoAtual = Estados.Jogo;
                                //som_sapo = Content.Load<SoundEffect>("Cena08_sapo");
                                //som_sapo.Play();

                            }

                        if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                            if (
                             Mouse.GetState().X > crocodilo.posicao.X &&
                             Mouse.GetState().X < crocodilo.posicao.X + crocodilo.tamanho.X &&
                             Mouse.GetState().Y > crocodilo.posicao.Y &&
                             Mouse.GetState().Y < crocodilo.posicao.Y + crocodilo.tamanho.Y)
                            {
                                crocodilo.quadro_atual = 0;
                                croco_anima = true;
                                //som_croco = Content.Load<SoundEffect>("Cena08_crocodilo");
                                //som_croco.Play();
                            }


                        if (lua_anima == true)
                        {
                            Animar_lua();
                        }
                        if (morcego_anima == true)
                        {
                            Animar_morcego();
                        }
                        if (sapo_anima == true)
                        {
                            Animar_sapo();
                            trocar = 1;
                            som1 = false;
                            som2 = true;
                        }
                        if (croco_anima == true)
                        {
                            Animar_crocodilo();
                        }
                        if (ani)
                        {

                            Animar_bebe();
                            Animar_unicornio();

                        }
                    }//termino da cena

                    #endregion

                    break;

                case Estados.Introducao:

                    break;

                case Estados.Jogo:
                    {
                        if (som2 == true)
                        {
                            MediaPlayer.Play(meuSom);
                            som2 = false;
                            MediaPlayer.IsRepeating = true;
                        }

                        #region JOGO
                        if (trocar == 1)//JOGO
                        {
                            verificar = true;
                            if (verificar)
                            {


                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quas.position.X &&
                                     Mouse.GetState().X < quas.position.X + quas.texture.Width &&
                                     Mouse.GetState().Y > quas.position.Y &&
                                     Mouse.GetState().Y < quas.position.Y + quas.texture.Height &&
                                     ((quas.position.Y < quaspace.position.Y && quas.position.Y > quaspace.position.Y - diferencay &&
                                     quas.position.X == quaspace.position.X) ||
                                     ((quas.position.Y > quaspace.position.Y && quas.position.Y < quaspace.position.Y + diferencay &&
                                     quas.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quas.position.X;
                                        quaspace.position.Y = quas.position.Y;
                                        quas.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quas.position.X &&
                                     Mouse.GetState().X < quas.position.X + quas.texture.Width &&
                                     Mouse.GetState().Y > quas.position.Y &&
                                     Mouse.GetState().Y < quas.position.Y + quas.texture.Height &&
                                     ((quas.position.X < quaspace.position.X && quas.position.X > quaspace.position.X - diferenca &&
                                     quas.position.Y == quaspace.position.Y) ||
                                     ((quas.position.X > quaspace.position.X && quas.position.X < quaspace.position.X + diferenca &&
                                     quas.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quas.position.X;
                                        quaspace.position.Y = quas.position.Y;
                                        quas.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quag.position.X &&
                                     Mouse.GetState().X < quag.position.X + quag.texture.Width &&
                                     Mouse.GetState().Y > quag.position.Y &&
                                     Mouse.GetState().Y < quag.position.Y + quag.texture.Height &&
                                     ((quag.position.Y < quaspace.position.Y && quag.position.Y > quaspace.position.Y - diferencay &&
                                     quag.position.X == quaspace.position.X) ||
                                     ((quag.position.Y > quaspace.position.Y && quag.position.Y < quaspace.position.Y + diferencay &&
                                     quag.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quag.position.X;
                                        quaspace.position.Y = quag.position.Y;
                                        quag.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quag.position.X &&
                                     Mouse.GetState().X < quag.position.X + quag.texture.Width &&
                                     Mouse.GetState().Y > quag.position.Y &&
                                     Mouse.GetState().Y < quag.position.Y + quag.texture.Height &&
                                     ((quag.position.X < quaspace.position.X && quag.position.X > quaspace.position.X - diferenca &&
                                     quag.position.Y == quaspace.position.Y) ||
                                     ((quag.position.X > quaspace.position.X && quag.position.X < quaspace.position.X + diferenca &&
                                     quag.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quag.position.X;
                                        quaspace.position.Y = quag.position.Y;
                                        quag.position = memory;
                                    }

                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quaa.position.X &&
                                     Mouse.GetState().X < quaa.position.X + quaa.texture.Width &&
                                     Mouse.GetState().Y > quaa.position.Y &&
                                     Mouse.GetState().Y < quaa.position.Y + quaa.texture.Height &&
                                     ((quaa.position.Y < quaspace.position.Y && quaa.position.Y > quaspace.position.Y - diferencay &&
                                     quaa.position.X == quaspace.position.X) ||
                                     ((quaa.position.Y > quaspace.position.Y && quaa.position.Y < quaspace.position.Y + diferencay &&
                                     quaa.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quaa.position.X;
                                        quaspace.position.Y = quaa.position.Y;
                                        quaa.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quaa.position.X &&
                                     Mouse.GetState().X < quaa.position.X + quaa.texture.Width &&
                                     Mouse.GetState().Y > quaa.position.Y &&
                                     Mouse.GetState().Y < quaa.position.Y + quaa.texture.Height &&
                                     ((quaa.position.X < quaspace.position.X && quaa.position.X > quaspace.position.X - diferenca &&
                                     quaa.position.Y == quaspace.position.Y) ||
                                     ((quaa.position.X > quaspace.position.X && quaa.position.X < quaspace.position.X + diferenca &&
                                     quaa.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quaa.position.X;
                                        quaspace.position.Y = quaa.position.Y;
                                        quaa.position = memory;
                                    }

                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quat.position.X &&
                                     Mouse.GetState().X < quat.position.X + quat.texture.Width &&
                                     Mouse.GetState().Y > quat.position.Y &&
                                     Mouse.GetState().Y < quat.position.Y + quat.texture.Height &&
                                     ((quat.position.Y < quaspace.position.Y && quat.position.Y > quaspace.position.Y - diferencay &&
                                     quat.position.X == quaspace.position.X) ||
                                     ((quat.position.Y > quaspace.position.Y && quat.position.Y < quaspace.position.Y + diferencay &&
                                     quat.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quat.position.X;
                                        quaspace.position.Y = quat.position.Y;
                                        quat.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quat.position.X &&
                                     Mouse.GetState().X < quat.position.X + quat.texture.Width &&
                                     Mouse.GetState().Y > quat.position.Y &&
                                     Mouse.GetState().Y < quat.position.Y + quat.texture.Height &&
                                     ((quat.position.X < quaspace.position.X && quat.position.X > quaspace.position.X - diferenca &&
                                     quat.position.Y == quaspace.position.Y) ||
                                     ((quat.position.X > quaspace.position.X && quat.position.X < quaspace.position.X + diferenca &&
                                     quat.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quat.position.X;
                                        quaspace.position.Y = quat.position.Y;
                                        quat.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quao.position.X &&
                                     Mouse.GetState().X < quao.position.X + quao.texture.Width &&
                                     Mouse.GetState().Y > quao.position.Y &&
                                     Mouse.GetState().Y < quao.position.Y + quao.texture.Height &&
                                     ((quao.position.Y < quaspace.position.Y && quao.position.Y > quaspace.position.Y - diferencay &&
                                     quao.position.X == quaspace.position.X) ||
                                     ((quao.position.Y > quaspace.position.Y && quao.position.Y < quaspace.position.Y + diferencay &&
                                     quao.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quao.position.X;
                                        quaspace.position.Y = quao.position.Y;
                                        quao.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quao.position.X &&
                                     Mouse.GetState().X < quao.position.X + quao.texture.Width &&
                                     Mouse.GetState().Y > quao.position.Y &&
                                     Mouse.GetState().Y < quao.position.Y + quao.texture.Height &&
                                     ((quao.position.X < quaspace.position.X && quao.position.X > quaspace.position.X - diferenca &&
                                     quao.position.Y == quaspace.position.Y) ||
                                     ((quao.position.X > quaspace.position.X && quao.position.X < quaspace.position.X + diferenca &&
                                     quao.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quao.position.X;
                                        quaspace.position.Y = quao.position.Y;
                                        quao.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quap.position.X &&
                                     Mouse.GetState().X < quap.position.X + quap.texture.Width &&
                                     Mouse.GetState().Y > quap.position.Y &&
                                     Mouse.GetState().Y < quap.position.Y + quap.texture.Height &&
                                     ((quap.position.Y < quaspace.position.Y && quap.position.Y > quaspace.position.Y - diferencay &&
                                     quap.position.X == quaspace.position.X) ||
                                     ((quap.position.Y > quaspace.position.Y && quap.position.Y < quaspace.position.Y + diferencay &&
                                     quap.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quap.position.X;
                                        quaspace.position.Y = quap.position.Y;
                                        quap.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quap.position.X &&
                                     Mouse.GetState().X < quap.position.X + quap.texture.Width &&
                                     Mouse.GetState().Y > quap.position.Y &&
                                     Mouse.GetState().Y < quap.position.Y + quap.texture.Height &&
                                     ((quap.position.X < quaspace.position.X && quap.position.X > quaspace.position.X - diferenca &&
                                     quap.position.Y == quaspace.position.Y) ||
                                     ((quap.position.X > quaspace.position.X && quap.position.X < quaspace.position.X + diferenca &&
                                     quap.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quap.position.X;
                                        quaspace.position.Y = quap.position.Y;
                                        quap.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quaaa.position.X &&
                                     Mouse.GetState().X < quaaa.position.X + quaaa.texture.Width &&
                                     Mouse.GetState().Y > quaaa.position.Y &&
                                     Mouse.GetState().Y < quaaa.position.Y + quaaa.texture.Height &&
                                     ((quaaa.position.Y < quaspace.position.Y && quaaa.position.Y > quaspace.position.Y - diferencay &&
                                     quaaa.position.X == quaspace.position.X) ||
                                     ((quaaa.position.Y > quaspace.position.Y && quaaa.position.Y < quaspace.position.Y + diferencay &&
                                     quaaa.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quaaa.position.X;
                                        quaspace.position.Y = quaaa.position.Y;
                                        quaaa.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quaaa.position.X &&
                                     Mouse.GetState().X < quaaa.position.X + quaaa.texture.Width &&
                                     Mouse.GetState().Y > quaaa.position.Y &&
                                     Mouse.GetState().Y < quaaa.position.Y + quaaa.texture.Height &&
                                     ((quaaa.position.X < quaspace.position.X && quaaa.position.X > quaspace.position.X - diferenca &&
                                     quaaa.position.Y == quaspace.position.Y) ||
                                     ((quaaa.position.X > quaspace.position.X && quaaa.position.X < quaspace.position.X + diferenca &&
                                     quaaa.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quaaa.position.X;
                                        quaspace.position.Y = quaaa.position.Y;
                                        quaaa.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quai.position.X &&
                                     Mouse.GetState().X < quai.position.X + quai.texture.Width &&
                                     Mouse.GetState().Y > quai.position.Y &&
                                     Mouse.GetState().Y < quai.position.Y + quai.texture.Height &&
                                     ((quai.position.Y < quaspace.position.Y && quai.position.Y > quaspace.position.Y - diferencay &&
                                     quai.position.X == quaspace.position.X) ||
                                     ((quai.position.Y > quaspace.position.Y && quai.position.Y < quaspace.position.Y + diferencay &&
                                     quai.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quai.position.X;
                                        quaspace.position.Y = quai.position.Y;
                                        quai.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quai.position.X &&
                                     Mouse.GetState().X < quai.position.X + quai.texture.Width &&
                                     Mouse.GetState().Y > quai.position.Y &&
                                     Mouse.GetState().Y < quai.position.Y + quai.texture.Height &&
                                     ((quai.position.X < quaspace.position.X && quai.position.X > quaspace.position.X - diferenca &&
                                     quai.position.Y == quaspace.position.Y) ||
                                     ((quai.position.X > quaspace.position.X && quai.position.X < quaspace.position.X + diferenca &&
                                     quai.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quai.position.X;
                                        quaspace.position.Y = quai.position.Y;
                                        quai.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quah.position.X &&
                                     Mouse.GetState().X < quah.position.X + quah.texture.Width &&
                                     Mouse.GetState().Y > quah.position.Y &&
                                     Mouse.GetState().Y < quah.position.Y + quah.texture.Height &&
                                     ((quah.position.Y < quaspace.position.Y && quah.position.Y > quaspace.position.Y - diferencay &&
                                     quah.position.X == quaspace.position.X) ||
                                     ((quah.position.Y > quaspace.position.Y && quah.position.Y < quaspace.position.Y + diferencay &&
                                     quah.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quah.position.X;
                                        quaspace.position.Y = quah.position.Y;
                                        quah.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quah.position.X &&
                                     Mouse.GetState().X < quah.position.X + quah.texture.Width &&
                                     Mouse.GetState().Y > quah.position.Y &&
                                     Mouse.GetState().Y < quah.position.Y + quah.texture.Height &&
                                     ((quah.position.X < quaspace.position.X && quah.position.X > quaspace.position.X - diferenca &&
                                     quah.position.Y == quaspace.position.Y) ||
                                     ((quah.position.X > quaspace.position.X && quah.position.X < quaspace.position.X + diferenca &&
                                     quah.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quah.position.X;
                                        quaspace.position.Y = quah.position.Y;
                                        quah.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quac.position.X &&
                                     Mouse.GetState().X < quac.position.X + quac.texture.Width &&
                                     Mouse.GetState().Y > quac.position.Y &&
                                     Mouse.GetState().Y < quac.position.Y + quac.texture.Height &&
                                     ((quac.position.Y < quaspace.position.Y && quac.position.Y > quaspace.position.Y - diferencay &&
                                     quac.position.X == quaspace.position.X) ||
                                     ((quac.position.Y > quaspace.position.Y && quac.position.Y < quaspace.position.Y + diferencay &&
                                     quac.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quac.position.X;
                                        quaspace.position.Y = quac.position.Y;
                                        quac.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quac.position.X &&
                                     Mouse.GetState().X < quac.position.X + quac.texture.Width &&
                                     Mouse.GetState().Y > quac.position.Y &&
                                     Mouse.GetState().Y < quac.position.Y + quac.texture.Height &&
                                     ((quac.position.X < quaspace.position.X && quac.position.X > quaspace.position.X - diferenca &&
                                     quac.position.Y == quaspace.position.Y) ||
                                     ((quac.position.X > quaspace.position.X && quac.position.X < quaspace.position.X + diferenca &&
                                     quac.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quac.position.X;
                                        quaspace.position.Y = quac.position.Y;
                                        quac.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quaaaa.position.X &&
                                     Mouse.GetState().X < quaaaa.position.X + quaaaa.texture.Width &&
                                     Mouse.GetState().Y > quaaaa.position.Y &&
                                     Mouse.GetState().Y < quaaaa.position.Y + quaaaa.texture.Height &&
                                     ((quaaaa.position.Y < quaspace.position.Y && quaaaa.position.Y > quaspace.position.Y - diferencay &&
                                     quaaaa.position.X == quaspace.position.X) ||
                                     ((quaaaa.position.Y > quaspace.position.Y && quaaaa.position.Y < quaspace.position.Y + diferencay &&
                                     quaaaa.position.X == quaspace.position.X))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quaaaa.position.X;
                                        quaspace.position.Y = quaaaa.position.Y;
                                        quaaaa.position = memory;
                                    }
                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                    if (
                                     Mouse.GetState().X > quaaaa.position.X &&
                                     Mouse.GetState().X < quaaaa.position.X + quaaaa.texture.Width &&
                                     Mouse.GetState().Y > quaaaa.position.Y &&
                                     Mouse.GetState().Y < quaaaa.position.Y + quaaaa.texture.Height &&
                                     ((quaaaa.position.X < quaspace.position.X && quaaaa.position.X > quaspace.position.X - diferenca &&
                                     quaaaa.position.Y == quaspace.position.Y) ||
                                     ((quaaaa.position.X > quaspace.position.X && quaaaa.position.X < quaspace.position.X + diferenca &&
                                     quaaaa.position.Y == quaspace.position.Y))))
                                    {
                                        memory = quaspace.position;
                                        quaspace.position.X = quaaaa.position.X;
                                        quaspace.position.Y = quaaaa.position.Y;
                                        quaaaa.position = memory;
                                    }
                                if (memoryant != memory)
                                {

                                    meuclic.Play();
                                }
                                if (
                                (quag.position.X == 320 && quag.position.Y == 210) &&
                                (quaa.position.X == 425 && quaa.position.Y == 210) &&
                                (quat.position.X == 530 && quat.position.Y == 210) &&
                                (quao.position.X == 635 && quao.position.Y == 210) &&
                                (quap.position.X == 320 && quap.position.Y == 315) &&
                                (quaaa.position.X == 425 && quaaa.position.Y == 315) &&
                                (quai.position.X == 530 && quai.position.Y == 315) &&
                                (quas.position.X == 635 && quas.position.Y == 315) &&
                                (quac.position.X == 320 && quac.position.Y == 420) &&
                                (quah.position.X == 425 && quah.position.Y == 420) &&
                                (quaaaa.position.X == 530 && quaaaa.position.Y == 420) &&
                                (quaspace.position.X == 635 && quaspace.position.Y == 420))
                                {
                                    venceu = 1;
                                }
                                if (venceu == 0)
                                {

                                    time += gameTime.ElapsedGameTime.TotalSeconds;
                                    timefinal = Convert.ToInt32(time);
                                }


                                if
                                     (
                                 (quag.position.X == 320 && quag.position.Y == 210) &&
                                 (quaa.position.X == 425 && quaa.position.Y == 210) &&
                                 (quat.position.X == 530 && quat.position.Y == 210) &&
                                 (quao.position.X == 635 && quao.position.Y == 210) ||
                                     (quag.position.X == 320 && quag.position.Y == 315) &&
                                 (quaa.position.X == 425 && quaa.position.Y == 315) &&
                                 (quat.position.X == 530 && quat.position.Y == 315) &&
                                 (quao.position.X == 635 && quao.position.Y == 315) ||
                                     (quag.position.X == 320 && quag.position.Y == 420) &&
                                 (quaa.position.X == 425 && quaa.position.Y == 420) &&
                                 (quat.position.X == 530 && quat.position.Y == 420) &&
                                 (quao.position.X == 635 && quao.position.Y == 420))

                                    if
                                          (
                                      (quag.position.X == 320 && quag.position.Y == 210) &&
                                      (quaa.position.X == 425 && quaa.position.Y == 210) &&
                                      (quat.position.X == 530 && quat.position.Y == 210) &&
                                      (quao.position.X == 635 && quao.position.Y == 210) ||
                                          (quag.position.X == 320 && quag.position.Y == 315) &&
                                      (quaa.position.X == 425 && quaa.position.Y == 315) &&
                                      (quat.position.X == 530 && quat.position.Y == 315) &&
                                      (quao.position.X == 635 && quao.position.Y == 315) ||
                                          (quag.position.X == 320 && quag.position.Y == 420) &&
                                      (quaa.position.X == 425 && quaa.position.Y == 420) &&
                                      (quat.position.X == 530 && quat.position.Y == 420) &&
                                      (quao.position.X == 635 && quao.position.Y == 420))
                                    {

                                        gato = "gato";
                                        checkgato = 1;

                                    }
                                    else
                                    {
                                        checkgato = 0;
                                    }
                                if
                                   (

                               (quap.position.X == 320 && quap.position.Y == 210) &&
                               (quaaa.position.X == 425 && quaaa.position.Y == 210) &&
                               (quai.position.X == 530 && quai.position.Y == 210) &&
                               (quas.position.X == 635 && quas.position.Y == 210) ||

                               (quap.position.X == 320 && quap.position.Y == 315) &&
                               (quaaa.position.X == 425 && quaaa.position.Y == 315) &&
                               (quai.position.X == 530 && quai.position.Y == 315) &&
                               (quas.position.X == 635 && quas.position.Y == 315) ||

                               (quap.position.X == 320 && quap.position.Y == 420) &&
                               (quaaa.position.X == 425 && quaaa.position.Y == 420) &&
                               (quai.position.X == 530 && quai.position.Y == 420) &&
                               (quas.position.X == 635 && quas.position.Y == 420))
                                {

                                    pais = "pais";
                                    checkpais = 1;

                                }
                                else
                                {
                                    checkpais = 0;
                                }



                                if
                                    (
                                (quac.position.X == 320 && quac.position.Y == 210) &&
                                (quah.position.X == 425 && quah.position.Y == 210) &&
                                (quaaaa.position.X == 530 && quaaaa.position.Y == 210) ||
                                   (quac.position.X == 320 && quac.position.Y == 315) &&
                                (quah.position.X == 425 && quah.position.Y == 315) &&
                                (quaaaa.position.X == 530 && quaaaa.position.Y == 315) ||
                               (quac.position.X == 320 && quac.position.Y == 420) &&
                                (quah.position.X == 425 && quah.position.Y == 420) &&
                                (quaaaa.position.X == 530 && quaaaa.position.Y == 420))
                                {
                                    cha = "cha";
                                    checkcha = 1;


                                }
                                else
                                {
                                    checkcha = 0;
                                }

                                memoryant = memory;

 
                            }//FIM DO IF VERIFICAR INUTIL
                        }//FIM DO TROCA 1 JOGO
                        #endregion
    
                    }
                    break;


                case Estados.SideQuest:
                    {
                        #region sidequest
                        if (!JogouSideQuest)
                        {
                           
                            //this.Window.Title = "X : " + v2dLagarto.X + " lar " + t2dLagarto.Width.ToString() + " mouse X : " + m.X + " mouse Y : " + m.Y;

                            if (sidebebe && JogarSidequest)
                            {
                                if (mouse_atual.LeftButton == ButtonState.Pressed)
                                {
                                    if (mouse_atual.X >= v2dPronto.X && mouse_atual.X <= v2dPronto.X + t2dPronto.Width &&
                                        mouse_atual.Y >= v2dPronto.Y && mouse_atual.Y <= v2dPronto.Y + t2dPronto.Height)
                                    {
                                        pronto = true;
                                        TempoPronto = true;
                                    }

                                    if (mouse_atual.X >= v2dGato.X && mouse_atual.X <= v2dGato.X + t2dGato.Width &&
                                        mouse_atual.Y >= v2dGato.Y && mouse_atual.Y <= v2dGato.Y + t2dGato.Height && UmaEscolha == false)
                                    {
                                        v2dGato = v2dPosi;
                                        Contador++;

                                        if (Contador == 1)
                                        {
                                            Escolha = 0;
                                            Contador = 0;
                                        }

                                        UmaEscolha = true;
                                    }

                                    if (mouse_atual.X >= v2dLagarto.X && mouse_atual.X <= v2dLagarto.X + t2dLagarto.Width &&
                                        mouse_atual.Y >= v2dLagarto.Y && mouse_atual.Y <= v2dLagarto.Y + t2dLagarto.Height && UmaEscolha == false)
                                    {
                                        v2dLagarto = v2dPosi;
                                        Contador = 2;
                                        if (Contador == 2)
                                        {
                                            Escolha = 1;
                                            Contador = 0;
                                        }
                                        UmaEscolha = true;
                                    }
                                    if (mouse_atual.X >= v2dRato.X && mouse_atual.X <= v2dRato.X + t2dRato.Width &&
                                        mouse_atual.Y >= v2dRato.Y && mouse_atual.Y <= v2dRato.Y + t2dRato.Height && UmaEscolha == false)
                                    {
                                        v2dRato = v2dPosi;
                                        Contador = 3;
                                        if (Contador == 3)
                                        {
                                            Escolha = 2;
                                            Contador = 0;
                                        }
                                        UmaEscolha = true;
                                    }
                                    ClickPronto = true;
                                }//FIM DO TESTE SE EU APERTEI O MOUSE


                                if (pronto && ClickPronto)
                                {
                                    Tempo = gameTime.ElapsedGameTime.Seconds;

                                    if (!sortiado)
                                    {
                                        EscolhaNPC = SortNPC.Next(0, 3);

                                        if (EscolhaNPC == Escolha)
                                        {
                                            Status = 2;
                                            if (Status == 2)
                                                EscolhaNPC = SortNPC.Next(0, 2);

                                        }
                                        else if ((Escolha == 0 && EscolhaNPC == 2) || (Escolha == 2 && EscolhaNPC == 1) || (Escolha == 1 && EscolhaNPC == 0))
                                        {
                                            Status = 0;
                                            sortiado = true;

                                            if (EscolhaNPC == 2)
                                            {
                                                v2dRato = v2dPosiNPC;
                                            }
                                            else if (EscolhaNPC == 1)
                                            {
                                                v2dLagarto = v2dPosiNPC;
                                            }
                                            else
                                                v2dGato = v2dPosiNPC;

                                            //sidebebe = false;
                                        }
                                        else if ((EscolhaNPC == 0 && Escolha == 2) || (EscolhaNPC == 2 && Escolha == 1) || (EscolhaNPC == 1 && Escolha == 0))
                                        {
                                            Status = 1;
                                            sortiado = true;
                                            if (EscolhaNPC == 2)
                                            {
                                                v2dRato = v2dPosiNPC;
                                            }
                                            else if (EscolhaNPC == 1)
                                            {
                                                v2dLagarto = v2dPosiNPC;
                                            }
                                            else
                                                v2dGato = v2dPosiNPC;
                                            // sidebebe = false;
                                        }

                                        if (Escolha != 90)
                                        {
                                            Resultado = true;
                                            Turno = false;
                                        }
                                    }
                                }

                                if ((mouse_atual.LeftButton == ButtonState.Pressed) && !(mouse_anterior.LeftButton == ButtonState.Pressed))
                                {
                                    if (mouse_atual.X >= v2dVoltar.X && mouse_atual.X <= v2dVoltar.X + t2dVoltar.Width
                                         && mouse_atual.Y >= v2dVoltar.Y && mouse_atual.Y <= v2dVoltar.Y + t2dVoltar.Height)
                                    {
                                        voltarCena = true;
                                        JogouSideQuest = true;
                                        sidebebe = false;
                                        estadoAtual = Estados.Cena;
                                    }
                                }

                            }//FIM SIDEQUEST

                        #endregion

                        }

                    }
                    break;

            }

            mouse_anterior = mouse_atual;
        }

        #endregion

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            switch (estadoAtual)
            {
                case Estados.Cena:

                    #region Cena
                    if (trocar == 0 || tela1)
                    {
                        if (venceu == 1)
                        {
                            spriteBatch.Draw(ganhou, Vector2.Zero, Color.White);
                            EnumCena.cenaAtual = EnumCena.Cena.cena9;
                        }



                        else
                        {
                            {//Cenario 1
                                spriteBatch.Draw(cenario_01.texture,
                                   new Rectangle(0, 0,
                                       cenario_01.texture.Width, cenario_01.texture.Height),
                                   new Rectangle((int)cenario_quadro01.X, (int)cenario_quadro01.Y,
                                       cenario_01.texture.Width, cenario_01.texture.Height),
                                       Color.White);
                                //lua
                                spriteBatch.Draw(lua.texture,
                                    new Rectangle((int)lua.posicao.X, (int)lua.posicao.Y,
                                       (int)lua.tamanho.X, (int)lua.tamanho.Y),
                                    new Rectangle((int)lua.posicao_q.X, (int)lua.posicao_q.Y,
                                       (int)lua.tamanho.X, (int)lua.tamanho.Y),
                                       Color.White);

                                //Cenario 2

                                spriteBatch.Draw(cenario_02.texture,
                                    new Rectangle(0, 0,
                                        cenario_02.texture.Width, cenario_02.texture.Height),
                                    new Rectangle((int)cenario_quadro02.X, (int)cenario_quadro02.Y,
                                        cenario_02.texture.Width, cenario_02.texture.Height),
                                        Color.White);

                                //Crocodilo
                                spriteBatch.Draw(crocodilo.texture,
                                    new Rectangle((int)crocodilo.posicao.X, (int)crocodilo.posicao.Y,
                                       (int)crocodilo.tamanho.X, (int)crocodilo.tamanho.Y),
                                    new Rectangle((int)crocodilo.posicao_q.X, (int)crocodilo.posicao_q.Y,
                                       (int)crocodilo.tamanho.X, (int)crocodilo.tamanho.Y),
                                       Color.White);

                                //Bebe porco
                                spriteBatch.Draw(bebe.texture,
                                     new Rectangle((int)bebe.posicao.X, (int)bebe.posicao.Y,
                                         (int)bebe.tamanho.X, (int)bebe.tamanho.Y),
                                     new Rectangle((int)bebe.posicao_q.X, (int)bebe.posicao_q.Y,
                                         (int)bebe.tamanho.X, (int)bebe.tamanho.Y),
                                         Color.White);


                                //Sapo
                                spriteBatch.Draw(sapo.texture,
                                    new Rectangle((int)sapo.posicao.X, (int)sapo.posicao.Y,
                                        (int)sapo.tamanho.X, (int)sapo.tamanho.Y),
                                    new Rectangle((int)sapo.posicao_q.X, (int)sapo.posicao_q.Y,
                                        (int)sapo.tamanho.X, (int)sapo.tamanho.Y),
                                        Color.White);

                                //Cenario 3
                                spriteBatch.Draw(cenario_03.texture,
                                    new Rectangle(0, 0,
                                        cenario_03.texture.Width, cenario_03.texture.Height),
                                    new Rectangle((int)cenario_quadro03.X, (int)cenario_quadro03.Y,
                                        cenario_03.texture.Width, cenario_03.texture.Height),
                                        Color.White);

                                //Morcego
                                spriteBatch.Draw(morcego.texture,
                                    new Rectangle((int)morcego.posicao.X, (int)morcego.posicao.Y,
                                       (int)morcego.tamanho.X, (int)morcego.tamanho.Y),
                                    new Rectangle((int)morcego.posicao_q.X, (int)morcego.posicao_q.Y,
                                       (int)morcego.tamanho.X, (int)morcego.tamanho.Y),
                                       Color.White);


                                //unicornio
                                spriteBatch.Draw(unicornio.texture,
                                    new Rectangle((int)unicornio.posicao.X, (int)unicornio.posicao.Y,
                                       (int)unicornio.tamanho.X, (int)unicornio.tamanho.Y),
                                    new Rectangle((int)unicornio.posicao_q.X, (int)unicornio.posicao_q.Y,
                                       (int)unicornio.tamanho.X, (int)unicornio.tamanho.Y),
                                       Color.White);

                                ani = true;

                                //spriteBatch.End();

                            }
                        }


                    }
                    #endregion

                    break;

                case Estados.Jogo:

                    #region Jogo

                    if (trocar == 1)
                    {

                        spriteBatch.Draw(fundo, Vector2.Zero, Color.Turquoise);
                        spriteBatch.Draw(fundo2, Vector2.Zero, Color.Turquoise);
                        spriteBatch.Draw(fundo3, Vector2.Zero, Color.Turquoise);

                        //spriteBatch.Draw(som2.texture, som2.position, Color.White);

                        spriteBatch.Draw(quag.texture, quag.position, Color.White);
                        spriteBatch.Draw(quaa.texture, quaa.position, Color.White);
                        spriteBatch.Draw(quat.texture, quat.position, Color.White);
                        spriteBatch.Draw(quao.texture, quao.position, Color.White);
                        spriteBatch.Draw(quap.texture, quap.position, Color.White);
                        spriteBatch.Draw(quaaa.texture, quaaa.position, Color.White);
                        spriteBatch.Draw(quai.texture, quai.position, Color.White);
                        spriteBatch.Draw(quas.texture, quas.position, Color.White);
                        spriteBatch.Draw(quac.texture, quac.position, Color.White);
                        spriteBatch.Draw(quah.texture, quah.position, Color.White);
                        spriteBatch.Draw(quaaaa.texture, quaaaa.position, Color.White);
                        spriteBatch.Draw(quaspace.texture, quaspace.position, Color.White);
                        {
                            if (time <= 60)
                            {
                                spriteBatch.Draw(tempogif, new Vector2(460, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(480, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(500, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(520, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(540, 550), Color.White);
                            }
                            if (time > 60 && time <= 120)
                            {
                                spriteBatch.Draw(tempogif, new Vector2(460, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(480, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(500, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(520, 550), Color.White);
                            }
                            if (time > 120 && time <= 180)
                            {
                                spriteBatch.Draw(tempogif, new Vector2(460, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(480, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(500, 550), Color.White);
                            }
                            if (time > 180 && time <= 240)
                            {
                                spriteBatch.Draw(tempogif, new Vector2(460, 550), Color.White);
                                spriteBatch.Draw(tempogif, new Vector2(480, 550), Color.White);
                            }
                            if (time > 240 && time <= 300)
                            {
                                spriteBatch.Draw(tempogif, new Vector2(460, 550), Color.White);
                            }
                            if (checkgato == 1)
                            {
                                spriteBatch.DrawString(font, gato.ToString(), new Vector2(310, 450), Color.White);
                            }
                            if (checkpais == 1)
                            {
                                spriteBatch.DrawString(font, pais.ToString(), new Vector2(310, 480), Color.White);
                            }
                            if (checkcha == 1)
                            {
                                spriteBatch.DrawString(font, cha.ToString(), new Vector2(310, 500), Color.White);
                            }
                            if (time > 300)
                            {
                                spriteBatch.Draw(perdeu, Vector2.Zero, Color.White);

                            }
                            if (time > 300 /*&& time < 60*/)
                            {
                                trocar = 0;
                                estadoAtual = Estados.Cena;
                                reinicio = 1;

                            }

                            if (venceu == 1)
                            {
                                spriteBatch.Draw(ganhou, Vector2.Zero, Color.Black);
                                EnumCena.cenaAtual = EnumCena.Cena.cena9;

                            }
                        }
                    }
                    #endregion


                    break;

                case Estados.SideQuest:

                    #region Sidequest

                    if (JogarSidequest && sidebebe)
                    {

                        spriteBatch.Draw(t2dGato, new Vector2(v2dGato.X, v2dGato.Y), Color.White);
                        spriteBatch.Draw(t2dLagarto, v2dLagarto, Color.Azure);
                        spriteBatch.Draw(t2dRato, new Vector2(v2dRato.X, v2dRato.Y), Color.White);
                        spriteBatch.Draw(t2dPronto, v2dPronto, Color.White);

                        if (Resultado && !Turno)
                        {
                            spriteBatch.Draw(t2dTela[Status], new Vector2(v2dTela.X, v2dTela.Y), Color.White);
                            spriteBatch.Draw(t2dVoltar, v2dVoltar, Color.White);
                        }
                        Turno = false;
                        seta.Desenhar(spriteBatch);
                    }



                    else if (!JogarSidequest || voltarCena)
                    {
                        if (venceu == 1)
                        {
                            trocar = 0;

                        }
                        if (time > 5)
                        {

                            trocar = 0;

                        }
                    }

                    #endregion

                    break;

                case Estados.Introducao:

                    break;


            }
            if (reinicio == 1)
            {
                time = 0;
                trocar = 0;
                sapo_anima = false;
                som1 = true;
                som2 = false;
                reinicio = 0;
            }
            seta.Desenhar(spriteBatch);
        }

        #region Bagunça

        void Animar_bebe()
        {
            //som_porco = Content.Load<SoundEffect>("Cena08_bebeporco");
            //som_porco.Play();
            bebe.tempo_quadro++;
            bebe.posicao_q.Y = 0;

            if (bebe.tempo_quadro > bebe.taxa_quadro)
            {
                if (bebe.quadro_atual < bebe.quadros_totais)
                {
                    bebe.posicao_q.X = bebe.tamanho.X * bebe.quadro_atual;
                    bebe.quadro_atual++;
                }
                else
                {
                    bebe.quadro_atual = 0;
                }
                bebe.tempo_quadro = 0;
            }
        }
        void Animar_sapo()
        {
            sapo.tempo_quadro++;
            sapo.posicao_q.Y = 0;

            if (sapo.tempo_quadro > sapo.taxa_quadro)
            {
                if (sapo.quadro_atual < sapo.quadros_totais)
                {
                    sapo.posicao_q.X = sapo.tamanho.X * sapo.quadro_atual;
                    sapo.quadro_atual++;
                }

                sapo.tempo_quadro = 0;
            }

        }
        void Animar_crocodilo()
        {
            crocodilo.tempo_quadro++;
            crocodilo.posicao_q.X = 0;

            if (crocodilo.tempo_quadro > crocodilo.taxa_quadro)
            {
                if (crocodilo.quadro_atual < crocodilo.quadros_totais)
                {
                    crocodilo.posicao_q.Y = crocodilo.tamanho.Y * crocodilo.quadro_atual;
                    crocodilo.quadro_atual++;
                }

                crocodilo.tempo_quadro = 0;
            }
        }
        void Animar_morcego()
        {
            morcego.tempo_quadro++;
            morcego.posicao_q.Y = 0;

            if (morcego.tempo_quadro > morcego.taxa_quadro)
            {
                if (morcego.quadro_atual < morcego.quadros_totais)
                {
                    morcego.posicao_q.X = morcego.tamanho.X * morcego.quadro_atual;
                    morcego.quadro_atual++;
                }
                else
                {
                    morcego.quadro_atual = 0;
                }
                morcego.tempo_quadro = 0;
            }
        }
        void Animar_unicornio()
        {
            unicornio.tempo_quadro++;
            unicornio.posicao_q.Y = 0;

            if (unicornio.tempo_quadro > unicornio.taxa_quadro)
            {
                if (unicornio.quadro_atual < unicornio.quadros_totais)
                {
                    unicornio.posicao_q.X = unicornio.tamanho.X * unicornio.quadro_atual;
                    unicornio.quadro_atual++;
                }
                else
                {
                    unicornio.quadro_atual = 0;
                }
                unicornio.tempo_quadro = 0;
            }
        }
        void Animar_lua()
        {
            lua.tempo_quadro++;
            lua.posicao_q.X = 0;

            if (lua.tempo_quadro > lua.taxa_quadro)
            {
                if (lua.quadro_atual < lua.quadros_totais)
                {
                    lua.posicao_q.Y = lua.tamanho.Y * lua.quadro_atual;
                    lua.quadro_atual++;
                }
                else
                {
                    lua.quadro_atual = 0;
                }
                lua.tempo_quadro = 0;
            }
        
        }

        //implemente aonde ele diz que ganha
        public void Ganhou()
        {
            //quando ganhar 
            HUD.spriteRelogio++;
        }

        #endregion
    }

    // TODO: Add your drawing code here
}

